// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed class MlFlushJobRequestParameters : RequestParameters<MlFlushJobRequestParameters>
	{
	}

	public sealed partial class MlFlushJobRequest : PlainRequestBase<MlFlushJobRequestParameters>
	{
		public MlFlushJobRequest(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningFlushJob;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("advance_time")]
		public DateTimeOffset? AdvanceTime { get; set; }

		[JsonInclude]
		[JsonPropertyName("calc_interim")]
		public bool? CalcInterim { get; set; }

		[JsonInclude]
		[JsonPropertyName("end")]
		public DateTimeOffset? End { get; set; }

		[JsonInclude]
		[JsonPropertyName("skip_time")]
		public DateTimeOffset? SkipTime { get; set; }

		[JsonInclude]
		[JsonPropertyName("start")]
		public DateTimeOffset? Start { get; set; }
	}

	public sealed partial class MlFlushJobRequestDescriptor<TDocument> : RequestDescriptorBase<MlFlushJobRequestDescriptor<TDocument>, MlFlushJobRequestParameters>
	{
		internal MlFlushJobRequestDescriptor(Action<MlFlushJobRequestDescriptor<TDocument>> configure) => configure.Invoke(this);
		public MlFlushJobRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlFlushJobRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningFlushJob;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlFlushJobRequestDescriptor<TDocument> JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		private DateTimeOffset? AdvanceTimeValue { get; set; }

		private bool? CalcInterimValue { get; set; }

		private DateTimeOffset? EndValue { get; set; }

		private DateTimeOffset? SkipTimeValue { get; set; }

		private DateTimeOffset? StartValue { get; set; }

		public MlFlushJobRequestDescriptor<TDocument> AdvanceTime(DateTimeOffset? advanceTime)
		{
			AdvanceTimeValue = advanceTime;
			return Self;
		}

		public MlFlushJobRequestDescriptor<TDocument> CalcInterim(bool? calcInterim = true)
		{
			CalcInterimValue = calcInterim;
			return Self;
		}

		public MlFlushJobRequestDescriptor<TDocument> End(DateTimeOffset? end)
		{
			EndValue = end;
			return Self;
		}

		public MlFlushJobRequestDescriptor<TDocument> SkipTime(DateTimeOffset? skipTime)
		{
			SkipTimeValue = skipTime;
			return Self;
		}

		public MlFlushJobRequestDescriptor<TDocument> Start(DateTimeOffset? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AdvanceTimeValue is not null)
			{
				writer.WritePropertyName("advance_time");
				JsonSerializer.Serialize(writer, AdvanceTimeValue, options);
			}

			if (CalcInterimValue.HasValue)
			{
				writer.WritePropertyName("calc_interim");
				writer.WriteBooleanValue(CalcInterimValue.Value);
			}

			if (EndValue is not null)
			{
				writer.WritePropertyName("end");
				JsonSerializer.Serialize(writer, EndValue, options);
			}

			if (SkipTimeValue is not null)
			{
				writer.WritePropertyName("skip_time");
				JsonSerializer.Serialize(writer, SkipTimeValue, options);
			}

			if (StartValue is not null)
			{
				writer.WritePropertyName("start");
				JsonSerializer.Serialize(writer, StartValue, options);
			}

			writer.WriteEndObject();
		}
	}

	public sealed partial class MlFlushJobRequestDescriptor : RequestDescriptorBase<MlFlushJobRequestDescriptor, MlFlushJobRequestParameters>
	{
		internal MlFlushJobRequestDescriptor(Action<MlFlushJobRequestDescriptor> configure) => configure.Invoke(this);
		public MlFlushJobRequestDescriptor(Elastic.Clients.Elasticsearch.Id job_id) : base(r => r.Required("job_id", job_id))
		{
		}

		internal MlFlushJobRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.MachineLearningFlushJob;
		protected override HttpMethod HttpMethod => HttpMethod.POST;
		protected override bool SupportsBody => true;
		public MlFlushJobRequestDescriptor JobId(Elastic.Clients.Elasticsearch.Id job_id)
		{
			RouteValues.Required("job_id", job_id);
			return Self;
		}

		private DateTimeOffset? AdvanceTimeValue { get; set; }

		private bool? CalcInterimValue { get; set; }

		private DateTimeOffset? EndValue { get; set; }

		private DateTimeOffset? SkipTimeValue { get; set; }

		private DateTimeOffset? StartValue { get; set; }

		public MlFlushJobRequestDescriptor AdvanceTime(DateTimeOffset? advanceTime)
		{
			AdvanceTimeValue = advanceTime;
			return Self;
		}

		public MlFlushJobRequestDescriptor CalcInterim(bool? calcInterim = true)
		{
			CalcInterimValue = calcInterim;
			return Self;
		}

		public MlFlushJobRequestDescriptor End(DateTimeOffset? end)
		{
			EndValue = end;
			return Self;
		}

		public MlFlushJobRequestDescriptor SkipTime(DateTimeOffset? skipTime)
		{
			SkipTimeValue = skipTime;
			return Self;
		}

		public MlFlushJobRequestDescriptor Start(DateTimeOffset? start)
		{
			StartValue = start;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (AdvanceTimeValue is not null)
			{
				writer.WritePropertyName("advance_time");
				JsonSerializer.Serialize(writer, AdvanceTimeValue, options);
			}

			if (CalcInterimValue.HasValue)
			{
				writer.WritePropertyName("calc_interim");
				writer.WriteBooleanValue(CalcInterimValue.Value);
			}

			if (EndValue is not null)
			{
				writer.WritePropertyName("end");
				JsonSerializer.Serialize(writer, EndValue, options);
			}

			if (SkipTimeValue is not null)
			{
				writer.WritePropertyName("skip_time");
				JsonSerializer.Serialize(writer, SkipTimeValue, options);
			}

			if (StartValue is not null)
			{
				writer.WritePropertyName("start");
				JsonSerializer.Serialize(writer, StartValue, options);
			}

			writer.WriteEndObject();
		}
	}
}